<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/html">
<head>
<%@ include file="/static/include/common.inc"%>
<title>青州市名卡管理系统</title>
<link rel="shortcut icon"
	href="https://github.com/shuaijunlan/Autumn-Framework/raw/master/favicon.ico"
	type="image/x-icon" />
<link rel="stylesheet" href="static/admin/css/layui.css">
<link rel="stylesheet" href="static/layui_v2.2.3/css/zbyui.css">
<link rel="stylesheet" href="static/admin/css/main.css" media="all">
<script src="static/js/jquery-1.11.2.js"></script>
<script src="static/layui_v2.2.3/layui.js" charset="utf-8"></script>
</head>
<body>
	<ul class="layui-tab-title">
		<c:choose>
			<c:when test="${manageType==3 }">
		    	<li class="layui-this">市民卡介绍</li>
			</c:when>
			<c:when test="${manageType==4 }">
		    	<li class="layui-this">市民卡使用手册</li>
			</c:when>
			<c:when test="${manageType==5 }">
		    	<li class="layui-this">市民卡相关政策文件</li>
			</c:when>
			<c:when test="${manageType==6 }">
		    	<li class="layui-this">市民卡发展历程</li>
			</c:when>
		</c:choose>
  	</ul>
	<div class="layui-tab-content">
		<div class="layui-tab-item layui-show" style="margin: 10px">
			<form class="layui-form" action="">
				<input name="articleId" value="${article.articleId }" id="articleId" style="display: none;">
				<input name="articleType" value="${manageType }" id="articleType" style="display: none;">
				<div class="layui-form-item">
					<label class="layui-form-label">名称</label>
					<div class="layui-input-block">
						<input type="text" name="articleName" required lay-verify="required"
							placeholder="请输入名称（如：）" autocomplete="off"
							class="layui-input" value="${article.articleName }" maxlength="64">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">发布时间</label>
					<div class="layui-input-block">
						<input type="text" name="releaseTimeStr" required
							lay-verify="required" placeholder="请输入发布时间" autocomplete="off"
							class="layui-input" id="releaseTimeStr" readonly="readonly" value="${article.releaseTimeStr }">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">阅读次数</label>
					<div class="layui-input-block">
						<input type="text" name="readNum" required lay-verify="number"
							placeholder="请输入阅读次数" autocomplete="off" class="layui-input" value="${article.readNum }">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">内容</label>
					<div class="layui-input-block">
						<input name="content" type="hidden" id="content">
						<!-- 加载编辑器的容器 -->
						<script id="container" type="text/plain">${article.content}</script>
		    		</div>
		    	</div>
				<div class="layui-form-item">
					<div class="layui-input-block">
						<button class="layui-btn" lay-submit lay-filter="formDemo">保存</button>
					</div>
				</div>
			</form>
		</div>
	</div>
	<!-- 配置文件 -->
	<script type="text/javascript" src="static/ueditor1433/ueditor.config.js"></script>
	<!-- 编辑器源码文件 -->
	<script type="text/javascript" src="static/ueditor1433/ueditor.all.min.js"></script>
	<script type="text/javascript">
		<!-- 实例化编辑器 -->
		var ue = UE.getEditor('container', {
			/* initialFrameWidth : $(".layui-input").attr("width"),*/
			initialFrameHeight : 450, 
		});
		//事件
		/* ue.addListener("contentChange",function(){
		    $("#content").val(ue.getContent());
		}); */
		layui.use([ 'form','laydate' ], function() {
			var form = layui.form;
			var laydate = layui.laydate;
			//执行一个laydate实例
			laydate.render({
				elem : '#releaseTimeStr' //指定元素
			});
			//监听提交
			form.on('submit(formDemo)', function(data) {
				data.field.content = ue.getContent();
				$(".layui-btn").addClass("layui-btn-disabled")
				$.ajax({
					type : "post",
					url : "admin/article/updateArticle.do",
					data : data.field,
					async: false,
					success : function(result) {
						if (result.code == 1) {
							layer.msg(result.msg);
							setTimeout(flushCurrentPage,100);
						} else {
							layer.msg(result.msg);
						}
					}
				});
				return false;
			});
		});
		function flushCurrentPage(){
			window.location.reload();
		}
	</script>
</body>
</html>